package com.king01.controller;

import com.king01.entity.Backlightcolor;
import com.king01.entity.Keyboardcolor;
import com.king01.entity.Shaftchoose;
import com.king01.service.GoodsService;
import com.king01.vo.GoodsVo;
import com.king01.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author：张梓康
 * @date：Created in 2023/9/26 17:39
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @RequestMapping("/list")
    public Result listGoods(Integer currentPage, Integer pageSize, @RequestBody GoodsVo goodsVo) {
        Result goods = goodsService.findAllGoods(currentPage, pageSize, goodsVo);
        System.out.println("-----"+goods);
        return goods;
    }

    @RequestMapping("/selectbranchid")
    public Integer selectbranchid(){
        Integer branchid = goodsService.selectbranchid();
        return branchid;
    }

    @RequestMapping("/keycap")
    public Result keyCap() {
        Result result = goodsService.findAllKeyCap();
        return result;
    }

    @RequestMapping("/keyboardcolor")
    public Result keyboardcolor(Integer currentPage, Integer pageSize, Integer status, @RequestBody Keyboardcolor keyboardcolor) {
        Result result = goodsService.findAllKeyBoardColor(currentPage, pageSize, keyboardcolor, status);
        return result;
    }

    @RequestMapping("/keyboardcolorAll")
    public Result keyboardcolorAll(){
        return goodsService.keyboardcolorAll();
    }


    @RequestMapping("/keyboardcolordel")
    public Integer keyboardcolordel(Integer keyboardcolorid) {
        Integer integer = goodsService.deleteKeyBoardColor(keyboardcolorid);
        return integer;
    }

    @RequestMapping("/shaftchoose")
    public Result shaftchoose(Integer currentPage, Integer pageSize, Integer status) {
        Result result = goodsService.findAllShaftChoose(currentPage, pageSize, status);
        return result;
    }

    @RequestMapping("/shaftchoosedel")
    public Integer shaftchoosedel(Integer shaftchooseid) {
        Integer integer = goodsService.deleteshaftchoose(shaftchooseid);
        return integer;
    }

    @RequestMapping("/backlightcolor")
    public Result backlightcolor(Integer currentPage, Integer pageSize, Integer status) {
        Result result = goodsService.findAllBackLightColor(currentPage, pageSize, status);
        return result;
    }

    @RequestMapping("/deletebacklightcolor")
    public Integer deletebacklightcolor(Integer backlightcolorid) {
        Integer integer = goodsService.deletebacklightcolor(backlightcolorid);
        return integer;
    }

    @RequestMapping("BranchList")
    public Result branchList(Integer currentPage, Integer pageSize) {
        Result result = goodsService.selectAllGoodsByBranch(currentPage, pageSize);

        System.out.println("------------------------" + result);
        return result;
    }

    @RequestMapping("/branch")
    public Result branch() {
        Result result = goodsService.findAllBranch();
        return result;
    }

    @RequestMapping("/delete")
    public Integer delete(Integer id) {
        Integer integer = goodsService.deleteGoods(id);
        return integer;
    }

    //   修改商品
    @RequestMapping("/update")
    public Integer update(@RequestBody GoodsVo goodsVo) {
        System.out.println(goodsVo);
        Integer integer = goodsService.updateGoods(goodsVo);
        return integer;
    }

    //    添加商品
    @RequestMapping("/add")
    public Integer addGoods(@RequestBody GoodsVo goodsVo) {
        System.out.println(goodsVo);
        Integer integer = goodsService.addGoods(goodsVo);
        return integer;
    }

    //    添加轴体类型
    @RequestMapping("/addshaftchoose")
    public Integer addshaftchoose(@RequestBody Shaftchoose shaftchoose) {
        System.out.println(shaftchoose + "++++++++++++++");
        Integer integer = goodsService.addshaftchoose(shaftchoose);
        return integer;
    }


    //    添加键盘颜色
    @RequestMapping("/addkeyboardcolor")
    public Integer addkeyboardcolor(@RequestBody Keyboardcolor keyboardcolor) {
        Integer integer = goodsService.addkeyboardcolor(keyboardcolor);
        return integer;
    }

    //    添加背光颜色
    @RequestMapping("/addbacklightcolor")
    public Integer addbacklightcolor(@RequestBody Backlightcolor backlightcolor) {
        Integer integer = goodsService.addbacklightcolor(backlightcolor);
        return integer;
    }

    //    修改键盘颜色
    @RequestMapping("/updatekeyboardcolor")
    public Integer updatekeyboardcolor(@RequestBody Keyboardcolor keyboardcolor) {
        Integer integer = goodsService.updatekeyboardcolor(keyboardcolor);
        return integer;
    }

    //    修改轴体类型
    @RequestMapping("/updateshaftchoose")
    public Integer updateshaftchoose(@RequestBody Shaftchoose shaftchoose) {
        Integer integer = goodsService.updateshaftchoose(shaftchoose);
        return integer;
    }

    //    修改背光颜色
    @RequestMapping("/updatebacklightcolor")
    public Integer updatebacklightcolor(@RequestBody Backlightcolor backlightcolor) {
        Integer integer = goodsService.updatebacklightcolor(backlightcolor);
        return integer;
    }
    @RequestMapping("/upload")
    public Result upload(MultipartFile headUrl){
        Result result = goodsService.imgUpload(headUrl);
        return result;
    }

    @RequestMapping("/uploadadd")
    public Result uploadadd(MultipartFile headUrl){
        Result result = goodsService.imgUpload(headUrl);
        return result;
    }
}
    